<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>New Event Creation Page</title>
    </h:head>
    <h:body>
        <h:form>
            <p:layout fullPage="true">
                <p:layoutUnit position="north" size="125" style="border: 0px">
                    <h:panelGrid columns="3" style="width: 100%">
                        <h:graphicImage value="/images/Simbolo_Meteocal.png" height="100"/>
                        <h1>Event Creation</h1>
                        <p:commandButton action="#{eventBean.abort()}" value="Abort the new event creation" immediate="true"/>
                    </h:panelGrid>
                </p:layoutUnit>
                <p:layoutUnit position="center">    
                    <p:panel id="pannello">

                        <h:panelGrid  columns="3" style="width: 100%" >

                            Event Name *:
                            <p:inputText id="nameevent" value="#{eventBean.event.name}" required="true" requiredMessage="Name is madatory"/>
                            <p:message id="nameeventmessage" for="nameevent"/>
                            Event Description:
                            <h:inputTextarea id="descevent" value="#{eventBean.event.description}" >
                                <p:ajax update="descevent"/>
                            </h:inputTextarea>
                            <h:outputText value=""/>
                            Event Type *:
                            <h:selectOneRadio id="eventtype" value="#{eventBean.type}" layout="pageDirection" required="true" requiredMessage="Type is mandatory">
                                <f:selectItem id="item2" itemLabel="Public Indoor Event" itemValue="1" />
                                <f:selectItem id="item3" itemLabel="Public Outdoor Event" itemValue="2" />
                                <f:selectItem id="item4" itemLabel="Private Indoor Event" itemValue="3" />
                                <f:selectItem id="item5" itemLabel="Private Outdoor Event" itemValue="4" />
                            </h:selectOneRadio>
                            <p:message id="eventtypemessage" for="eventtype"/>

                            Begin Date *:
                            <p:calendar id="datetime" value="#{eventBean.beginDate}" pattern="MM/dd/yyyy HH:mm" required="true" requiredMessage="Begin date is mandatory" mindate="#{eventBean.today}">
                                <p:ajax event="dateSelect" update="datetime2" />
                            </p:calendar>
                            <p:message id="datetimemessage" for="datetime"/>
                            End Date *:
                            <p:calendar id="datetime2" value="#{eventBean.endDate}" pattern="MM/dd/yyyy HH:mm" required="true" requiredMessage="End date is mandatory" mindate="#{eventBean.beginDate}"/>   
                            <p:message id="datetime2message" for="datetime2"/>
                            City *:
                            <p:inputText id="cityevent" value="#{eventBean.event.city}" required="true" requiredMessage="City si mandatory"/>
                            <p:message id="cityeventmessage" for="cityevent"/>
                            Country *:
                            <p:inputText id="countryevent" value="#{eventBean.event.country}" required="true" requiredMessage="Country si mandatory"/>
                            <p:message for="countryevent"/>
                            Address:
                            <h:inputText id="addressevent" value="#{eventBean.event.address}"/>
                            <h:outputText value=""/>
                        </h:panelGrid>       
                        Participants list: <br/>
                        <h:outputText id="participants" value="#{eventBean.invitedUsers}" style="white-space: pre-wrap;"/>
                        <hr/>
                        <br/> 
                        <p:inputText type="email" id="emailparticipan" value="#{eventBean.invitedUser}">
                            <f:ajax/>
                        </p:inputText>
                        <p:commandButton update="participants" value="Add a Participant" action="#{eventBean.checkUser()}" immediate="true" />
                        <p:messages globalOnly="true" autoUpdate="true"  id="errrrrr"/>

                        <br/>
                        <p:commandButton value="Save" action="#{eventBean.save()}" update="pannello" />
                        <br/>
                        The * elements are mandatorial elements.
                    </p:panel>
                </p:layoutUnit>
            </p:layout>
        </h:form>
    </h:body>
</html>

